<?php
	session_start();
	$auth = isset($_SESSION['s_auth']['identifikasi_titik']) ? $_SESSION['s_auth']['identifikasi_titik'] : NULL;	
	
	if( $auth == NULL || $auth == 'view' ){
		die('&copy; 2009 Mekarsari Web-GIS');
	}	
	
	$pancang_id	= isset($_POST['id'])? $_POST['id'] : 1;	
?>
		<style>
		#insertForm input[type=text]{
				font-family: Georgia, "Times New Roman", Times, serif;
				font-size: 11px;
		}
		</style>
		<script language="javascript">
		var insert = {	
				param: '',
				send: function(form){
					// validasi dulu
					for(var i=0; i<form.elements.length; i++){
						el = form.elements[i];
						
						if(el.type == 'text' && el.value.length < 1){
							alert('Field "'+el.name+'"tidak boleh kosong');
							el.focus();
							return false;
						}
					}
					
					this.param = '';
					for(var i=0; i<form.elements.length; i++){
						el = form.elements[i];
						
						if(el.type == 'text'){
							this.param += el.name+'='+el.value+'&';
						}
					}
					
					this.param = this.param + 'mode=insert'; // tambahkan mode request..
					
					myUpdate.send(this.param);
					return false;
				}
		}
		
		// cek angka		
		function cekAngka(el){
			var invalidNumber = /[^0-9.,]/;
			if ( invalidNumber.test(el.value) ){
				alert('Harus angka');
				el.value = '';
				el.focus();
			}
		}
		</script>
		<form method="post" action="process.php" name="insertForm" id="insertForm" onsubmit="return insert.send(this);return false;">
		<div id="log"></div>
		<table width="296" cellpadding="3" cellspacing="0">		
		  <tr>
			<td><div align="left">No Pancang </div></td>
			<td>:</td>
			<td>
	          <input name="no_pancang" type="text" id="no_pancang" value="<?=$pancang_id;?>" disabled="disabled"/>	    
	        <div align="left"></div></td>
		  </tr>
		  <tr>
			<td width="129"><div align="left">No Individu </div></td>
			<td width="3">:</td>
			<td width="144"><input type="text" name="no_individu" id="no_individu" value=""/>
		    <div align="left"></div></td>
		  </tr>
		  <tr>
			<td><div align="left">Tanggal Tanam </div></td>
			<td>:</td>
			<td valign="middle" nowrap="nowrap">
	          <div align="left">
	            <input name="tgl_tanam" type="text" id="tgl_tanam" size="15" readonly="readonly" value="<?=date('Y-m-d', time());?>"/>          
	            <img src="images/calendar.png" onclick="displayDatePicker('tgl_tanam');" >
		    </div></td>
		  </tr>
		  <tr>
			<td><div align="left">Replika </div></td>
			<td>:</td>
			<td>
	          <input name="replika" type="text" id="replika" value="" />	    
	        <div align="left"></div></td>
		  </tr>
		  <tr>
			<td><div align="left">Usia Saat Tanam </div></td>
			<td>:</td>
			<td>
	          <input name="usia_saat_tanam" type="text" id="usia_saat_tanam" value="" onchange="cekAngka(this)" />	    
	        <div align="left"></div></td>
		  </tr>
		  <tr>
			<td><div align="left">Crossing Asal Pokok </div></td>
			<td>:</td>
			<td>
	          <input name="cross_asal_pokok" type="text" id="cross_asal_pokok" value="" />	    
	        <div align="left"></div></td>
		  </tr>
		  <tr>
			<td><div align="left">Jenis Tanaman </div></td>
			<td>:</td>
			<td>
	          <input name="jenis_tanaman" type="text" id="jenis_tanaman" value="" />	    
	        <div align="left"></div></td>
		  </tr>
		  <tr>
			<td><div align="left">Ketegori Pokok Saat Tanam </div></td>
			<td>:</td>
			<td>
	          <input name="kategori_pokok_saat_tanam" type="text" id="kategori_pokok_saat_tanam" value="" />	    
	        <div align="left"></div></td>
		  </tr>
		  <tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td><div align="left"></div></td>
		  </tr>
		  <tr>
			<td colspan="3"><div align="center">&nbsp;
				<input type="submit" name="submit" value="Insert"/>&nbsp;
				<input type="reset" name="reset" value="Reset" />&nbsp;
				<input type="button" name="back" value="Cancel" onclick="myRequest.send('id=<?=$pancang_id;?>');" />
			</div></td>
		  </tr>			  
		  </table>
		</form>	
	